package org.example.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;  // 修正Page导入
import org.example.entity.MeetingQueryDTO;
import org.example.entity.Meeting;
import org.example.mapper.MeetingMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class MeetingService {
    @Resource
    private MeetingMapper meetingMapper;

    /**
     * 分页查询会议列表
     */
    public IPage<Meeting> getMeetingList(MeetingQueryDTO query) {
        // 使用MyBatis-Plus的Page而非Spring Data的Page
        Page<Meeting> page = new Page<>(query.getPageNum(), query.getPageSize());
        return meetingMapper.queryMeetingList(page, query);
    }

    /**
     * 导出会议数据
     */
    public List<Meeting> exportMeetingList(MeetingQueryDTO query) {
        // 不分页查询所有符合条件的数据
        Page<Meeting> page = new Page<>(1, Integer.MAX_VALUE);
        IPage<Meeting> resultPage = meetingMapper.queryMeetingList(page, query);
        return resultPage.getRecords();
    }

    /**
     * 获取会议详情
     */
    public Meeting getMeetingDetail(Integer id) {
        return meetingMapper.selectById(id);
    }
}